<?php

namespace app\admin\model;

use think\Model;


class CouponExchange extends Model
{

    

    

    // 表名
    protected $table = 'coupon_exchange';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'unit_text',
        'start_time_mold_text',
        'status_text'
    ];
    

    
    public function getUnitList()
    {
        return ['year' => __('Unit year'), 'mouth' => __('Unit mouth'), 'week' => __('Unit week'), 'day' => __('Unit day')];
    }


    public function getUnitTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['unit']) ? $data['unit'] : '');
        $list = $this->getUnitList();
        return isset($list[$value]) ? $list[$value] : '';
    }



    public function getStartTimeMoldList()
    {
        return ['now' => __('Start_time_mold now'), 'next' => __('Start_time_mold next')];
    }


    public function getStartTimeMoldTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['start_time_mold']) ? $data['start_time_mold'] : '');
        $list = $this->getUnitList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
